{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "### 字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "face_verify=[{'faceId': 'f4cb74c1-08b7-4701-b20e-c55223fbe0b7',\n",
    "  'faceRectangle': {'top': 49, 'left': 139, 'width': 41, 'height': 41},\n",
    "  'faceAttributes': {'smile': 1.0,\n",
    "   'gender': 'male',\n",
    "   'age': 32.0,\n",
    "   'glasses': 'NoGlasses',\n",
    "   'hair': {'bald': 0.07,\n",
    "    'invisible': False,\n",
    "    'hairColor': [{'color': 'brown', 'confidence': 0.99},\n",
    "     {'color': 'black', 'confidence': 0.81},\n",
    "     {'color': 'gray', 'confidence': 0.34},\n",
    "     {'color': 'blond', 'confidence': 0.22},\n",
    "     {'color': 'red', 'confidence': 0.13},\n",
    "     {'color': 'other', 'confidence': 0.08},\n",
    "     {'color': 'white', 'confidence': 0.0}]}}},\n",
    " {'faceId': 'ecdad0d7-01d1-4e35-ae0e-6582ad4336dc',\n",
    "  'faceRectangle': {'top': 45, 'left': 234, 'width': 39, 'height': 39},\n",
    "  'faceAttributes': {'smile': 1.0,\n",
    "   'gender': 'male',\n",
    "   'age': 33.0,\n",
    "   'glasses': 'NoGlasses',\n",
    "   'hair': {'bald': 0.34,\n",
    "    'invisible': False,\n",
    "    'hairColor': [{'color': 'black', 'confidence': 0.95},\n",
    "     {'color': 'brown', 'confidence': 0.9},\n",
    "     {'color': 'gray', 'confidence': 0.59},\n",
    "     {'color': 'blond', 'confidence': 0.29},\n",
    "     {'color': 'other', 'confidence': 0.2},\n",
    "     {'color': 'red', 'confidence': 0.04},\n",
    "     {'color': 'white', 'confidence': 0.0}]}}},\n",
    " {'faceId': '1b5ac7da-5de0-4a69-a378-b9acfe180e73',\n",
    "  'faceRectangle': {'top': 56, 'left': 337, 'width': 39, 'height': 39},\n",
    "  'faceAttributes': {'smile': 1.0,\n",
    "   'gender': 'male',\n",
    "   'age': 30.0,\n",
    "   'glasses': 'NoGlasses',\n",
    "   'hair': {'bald': 0.56,\n",
    "    'invisible': False,\n",
    "    'hairColor': [{'color': 'black', 'confidence': 0.95},\n",
    "     {'color': 'brown', 'confidence': 0.94},\n",
    "     {'color': 'gray', 'confidence': 0.8},\n",
    "     {'color': 'other', 'confidence': 0.17},\n",
    "     {'color': 'blond', 'confidence': 0.13},\n",
    "     {'color': 'red', 'confidence': 0.03},\n",
    "     {'color': 'white', 'confidence': 0.0}]}}}]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "glass=[]\n",
    "smiling=[]\n",
    "hair_color=[]\n",
    "age=[]\n",
    "gender=[]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "age的集合:[32.0, 33.0, 30.0]\n"
     ]
    }
   ],
   "source": [
    "### 年龄\n",
    "age.append(face_verify[0]['faceAttributes']['age'])\n",
    "age.append(face_verify[1]['faceAttributes']['age'])\n",
    "age.append(face_verify[2]['faceAttributes']['age'])\n",
    "print('age的集合:%s'%age)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "glass的集合:['NoGlasses', 'NoGlasses', 'NoGlasses']\n"
     ]
    }
   ],
   "source": [
    "### 眼镜\n",
    "glass.append(face_verify[0]['faceAttributes']['glasses'])\n",
    "glass.append(face_verify[1]['faceAttributes']['glasses'])\n",
    "glass.append(face_verify[2]['faceAttributes']['glasses'])\n",
    "print('glass的集合:%s'%glass)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gender的集合:['male', 'male', 'male']\n"
     ]
    }
   ],
   "source": [
    "### 性别\n",
    "gender.append(face_verify[0]['faceAttributes']['gender'])\n",
    "gender.append(face_verify[1]['faceAttributes']['gender'])\n",
    "gender.append(face_verify[2]['faceAttributes']['gender'])\n",
    "print('gender的集合:%s'%gender)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "此值介于 0（未微笑）与 1（明确的微笑）之间。smiling的集合:[1.0, 1.0, 1.0]\n"
     ]
    }
   ],
   "source": [
    "### 微笑\n",
    "smiling.append(face_verify[0]['faceAttributes']['smile'])\n",
    "smiling.append(face_verify[1]['faceAttributes']['smile'])\n",
    "smiling.append(face_verify[2]['faceAttributes']['smile'])\n",
    "print('此值介于 0（未微笑）与 1（明确的微笑）之间。smiling的集合:%s'%smiling)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hair_color的集合(选取confidence值最高):['brown', 'black', 'black']\n"
     ]
    }
   ],
   "source": [
    "### 发色\n",
    "hair_color.append(face_verify[0]['faceAttributes']['hair']['hairColor'][0]['color'])\n",
    "hair_color.append(face_verify[1]['faceAttributes']['hair']['hairColor'][0]['color'])\n",
    "hair_color.append(face_verify[2]['faceAttributes']['hair']['hairColor'][0]['color'])\n",
    "print('hair_color的集合(选取confidence值最高):%s'%hair_color)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
